#!/usr/bin/env python
#coding:utf-8

import urllib
import re

def download(name):
    #f = urllib.urlopen("http://220.181.26.78/gecisearch.so?query=" + name + "&as=false&st=&ac=1&pf=&class=5&http%3A%2F%2F220.181.26.78%2Fgecisearch.so=")
    #f = urllib.urlopen("http://mp3.sogou.com/music.so?pf=&as=&st=&ac=1&query="+ name +"&class=1&http%3A%2F%2Fmp3.sogou.com%2Fmusic.so=&_asf=mp3.sogou.com&_ast=1233212103&w=02009900")
    f = urllib.urlopen("http://mp3.sogou.com/music.so?query="+name+"&as=false&st=&ac=1&pf=&class=1")
    page = f.read()
    pattern = r'LRC.*'
    m =re.compile(pattern).findall(page)
    if m:
        print m[0]
    f = urllib.urlopen("http://mp3.sogou.com/"+m[0])
    lyrics = f.read()
    print lyrics

if __name__ == '__main__':
    download('jay')
